package cn.wolfcode.wolf2w.util;

import cn.wolfcode.wolf2w.exception.LogicException;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

/**
 * 参数断言的判断工具类
 */
public class AssertUtil {
    private AssertUtil(){}  // 私有化

    // 判断文本是否为null,""," "
    public static void hasLength(String text, String msg) {
        if (!StringUtils.hasLength(text)) {
            throw new LogicException(msg);
        }
    }

    // 判断两个文本是否一致
    public static void isEqual(String text1, String text2, String msg) {
        if (!StringUtils.hasLength(text1) || !StringUtils.hasLength(text2)) {
            throw new LogicException("输入不能为空");
        }
        if(!text1.equals(text2)) {
            throw new LogicException(msg);
        }
    }

}
